package com.blog.vueblogx.controller;


import com.blog.vueblogx.common.lang.Result;
import com.blog.vueblogx.entity.User;
import com.blog.vueblogx.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 关注公众号：MarkerHub
 * @since 2022-02-13
 */
@RestController
@RequestMapping("/user")
public class UserController {
   @Autowired
   private UserService userService;

   @RequiresAuthentication
   @RequestMapping("/test")
   public Object test() {
       User user = userService.getById(1L);
       return user;
   }

   @RequestMapping("/save")
   public Result save(@Validated @RequestBody User user) {
       return Result.success(user);
   }
}
